Skip to main content

Last Update: 2025/3/26

Qwen Embedding API

The Qwen Embedding API allows you to generate vector representations of text using OpenAI's SDK. This document provides an overview of the API endpoints, request parameters, and response structure.

Endpoint

POST https://platform.llmprovider.ai/v1/embeddings

Request Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Request Body

The request body should be a JSON object with the following parameters:

ParameterTypeDescription
modelstringThe model to use (e.g., text-embedding-v3).
inputstringThe input text to embed.
encoding_formatstring(Optional) The format to return the embeddings in. Can be either float or base64.
dimensionsinteger(Optional) The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.
userstring(Optional) A unique identifier representing the end-user.

Example Request

{
"model": "text-embedding-v3",
"input": "The quick brown fox jumps over the lazy dog.",
"user": "user-1234"
}

Response Body

The response body will be a JSON object containing the generated embeddings and other metadata.

FieldTypeDescription
objectstringThe type of object returned, usually embedding.
dataarrayA list of embedding objects.
modelstringThe model used for the embedding.
usageobjectToken usage statistics for the request.

Embedding Object

FieldTypeDescription
indexintegerThe index of the embedding in the list of embeddings.
embeddingarrayThe embedding vector.
objectstringThe object type, which is always "embedding".

Example Response

{
"object": "embedding",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
...
],
"index": 0
}
],
"model": "text-embedding-v3",
"usage": {
"prompt_tokens": 9,
"total_tokens": 9
}
}

Example Requests

curl -X POST https://platform.llmprovider.ai/v1/embeddings \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The food was delicious and the waiter...",
"model": "text-embedding-v3",
"encoding_format": "float"
}'

For any questions or further assistance, please contact us at [email protected].